import java.text.DecimalFormat;

/**
 * RadioGUI.java
 * @author Oscar Castañeda, Carnet 11086
 * @author Edwin Xico, Carnet 11090
 * @since 08/07/2012
 * Descripción: Interfaz gráfica para la radio, con botones para encender, cambiar de banda,
 * subir en la frecuencia y 12 botones para memoria.
 */

public class RadioGUI extends javax.swing.JFrame {

    //**Atributos para control de tiempo**
    private long inicioTiempo;
    private long finalTiempo;
    private DecimalFormat num = new DecimalFormat("#0.0");
            
    private Radio Radio = new RadioCarro(); //Cambiar aquí el nombre de la implementación.
    /**
     * Creates new form RadioGUI
     */
    public RadioGUI() {
        initComponents();
        disableRadio();
        if(Radio.isAM()){
        Radio.cambiarBanda();
    }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLP_Band = new javax.swing.JLayeredPane();
        jRB_AM = new javax.swing.JRadioButton();
        jRB_FM = new javax.swing.JRadioButton();
        jLP_Tune = new javax.swing.JLayeredPane();
        jB_Up = new javax.swing.JButton();
        jLP_MemoryButtons = new javax.swing.JLayeredPane();
        jB_M1 = new javax.swing.JButton();
        jB_M2 = new javax.swing.JButton();
        jB_M3 = new javax.swing.JButton();
        jB_M4 = new javax.swing.JButton();
        jB_M5 = new javax.swing.JButton();
        jB_M6 = new javax.swing.JButton();
        jB_M7 = new javax.swing.JButton();
        jB_M8 = new javax.swing.JButton();
        jB_M9 = new javax.swing.JButton();
        jB_M10 = new javax.swing.JButton();
        jB_M11 = new javax.swing.JButton();
        jB_M12 = new javax.swing.JButton();
        jTA_Pantalla = new javax.swing.JTextArea();
        jTB_OnOff = new javax.swing.JToggleButton();
        jL_Title = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jLP_Band.setBorder(javax.swing.BorderFactory.createTitledBorder("Band"));

        jRB_AM.setText("AM");
        jRB_AM.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jRB_AMMouseReleased(evt);
            }
        });
        jRB_AM.setBounds(10, 60, 50, 23);
        jLP_Band.add(jRB_AM, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jRB_FM.setSelected(true);
        jRB_FM.setText("FM");
        jRB_FM.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jRB_FMMouseReleased(evt);
            }
        });
        jRB_FM.setBounds(10, 20, 50, 23);
        jLP_Band.add(jRB_FM, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLP_Tune.setBorder(javax.swing.BorderFactory.createTitledBorder("Tune"));

        jB_Up.setBackground(new java.awt.Color(51, 102, 255));
        jB_Up.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_Up.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/pics/Up.png"))); // NOI18N
        jB_Up.setToolTipText("");
        jB_Up.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_Up.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_UpMouseReleased(evt);
            }
        });
        jB_Up.setBounds(10, 20, 50, 40);
        jLP_Tune.add(jB_Up, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLP_MemoryButtons.setBorder(javax.swing.BorderFactory.createTitledBorder("Memory"));

        jB_M1.setBackground(new java.awt.Color(51, 102, 255));
        jB_M1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jB_M1.setText("1");
        jB_M1.setToolTipText("");
        jB_M1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M1MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M1MouseReleased(evt);
            }
        });
        jB_M1.setBounds(10, 20, 50, 40);
        jLP_MemoryButtons.add(jB_M1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M2.setBackground(new java.awt.Color(51, 102, 255));
        jB_M2.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M2.setText("2");
        jB_M2.setToolTipText("");
        jB_M2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M2MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M2MouseReleased(evt);
            }
        });
        jB_M2.setBounds(70, 20, 50, 40);
        jLP_MemoryButtons.add(jB_M2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M3.setBackground(new java.awt.Color(51, 102, 255));
        jB_M3.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M3.setText("3");
        jB_M3.setToolTipText("");
        jB_M3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M3MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M3MouseReleased(evt);
            }
        });
        jB_M3.setBounds(130, 20, 50, 40);
        jLP_MemoryButtons.add(jB_M3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M4.setBackground(new java.awt.Color(51, 102, 255));
        jB_M4.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M4.setText("4");
        jB_M4.setToolTipText("");
        jB_M4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M4MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M4MouseReleased(evt);
            }
        });
        jB_M4.setBounds(190, 20, 50, 40);
        jLP_MemoryButtons.add(jB_M4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M5.setBackground(new java.awt.Color(51, 102, 255));
        jB_M5.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M5.setText("5");
        jB_M5.setToolTipText("");
        jB_M5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M5MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M5MouseReleased(evt);
            }
        });
        jB_M5.setBounds(250, 20, 50, 40);
        jLP_MemoryButtons.add(jB_M5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M6.setBackground(new java.awt.Color(51, 102, 255));
        jB_M6.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M6.setText("6");
        jB_M6.setToolTipText("");
        jB_M6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M6MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M6MouseReleased(evt);
            }
        });
        jB_M6.setBounds(310, 20, 50, 40);
        jLP_MemoryButtons.add(jB_M6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M7.setBackground(new java.awt.Color(51, 102, 255));
        jB_M7.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M7.setText("7");
        jB_M7.setToolTipText("");
        jB_M7.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M7MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M7MouseReleased(evt);
            }
        });
        jB_M7.setBounds(10, 70, 50, 40);
        jLP_MemoryButtons.add(jB_M7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M8.setBackground(new java.awt.Color(51, 102, 255));
        jB_M8.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M8.setText("8");
        jB_M8.setToolTipText("");
        jB_M8.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M8MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M8MouseReleased(evt);
            }
        });
        jB_M8.setBounds(70, 70, 50, 40);
        jLP_MemoryButtons.add(jB_M8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M9.setBackground(new java.awt.Color(51, 102, 255));
        jB_M9.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M9.setText("9");
        jB_M9.setToolTipText("");
        jB_M9.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M9.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M9MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M9MouseReleased(evt);
            }
        });
        jB_M9.setBounds(130, 70, 50, 40);
        jLP_MemoryButtons.add(jB_M9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M10.setBackground(new java.awt.Color(51, 102, 255));
        jB_M10.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M10.setText("10");
        jB_M10.setToolTipText("");
        jB_M10.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M10.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M10MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M10MouseReleased(evt);
            }
        });
        jB_M10.setBounds(190, 70, 50, 40);
        jLP_MemoryButtons.add(jB_M10, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M11.setBackground(new java.awt.Color(51, 102, 255));
        jB_M11.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M11.setText("11");
        jB_M11.setToolTipText("");
        jB_M11.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M11.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M11MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M11MouseReleased(evt);
            }
        });
        jB_M11.setBounds(250, 70, 50, 40);
        jLP_MemoryButtons.add(jB_M11, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jB_M12.setBackground(new java.awt.Color(51, 102, 255));
        jB_M12.setFont(new java.awt.Font("Tahoma", 1, 24));
        jB_M12.setText("12");
        jB_M12.setToolTipText("");
        jB_M12.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jB_M12.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_M12MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_M12MouseReleased(evt);
            }
        });
        jB_M12.setBounds(310, 70, 50, 40);
        jLP_MemoryButtons.add(jB_M12, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTA_Pantalla.setBackground(new java.awt.Color(0, 0, 0));
        jTA_Pantalla.setColumns(20);
        jTA_Pantalla.setFont(new java.awt.Font("Monospaced", 1, 48));
        jTA_Pantalla.setForeground(new java.awt.Color(102, 204, 255));
        jTA_Pantalla.setRows(5);
        jTA_Pantalla.setText("00.0");
        jTA_Pantalla.setAlignmentX(1.0F);
        jTA_Pantalla.setCaretColor(new java.awt.Color(102, 204, 255));
        jTA_Pantalla.setDisabledTextColor(new java.awt.Color(153, 204, 255));
        jTA_Pantalla.setSelectedTextColor(new java.awt.Color(102, 204, 255));

        jTB_OnOff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/pics/on-off.jpg"))); // NOI18N
        jTB_OnOff.setActionCommand("jTB_Up");
        jTB_OnOff.setBorder(null);
        jTB_OnOff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTB_OnOffActionPerformed(evt);
            }
        });

        jL_Title.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 36));
        jL_Title.setText("Radio");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jLP_Band, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLP_Tune, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(9, 9, 9)
                                .addComponent(jTB_OnOff, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLP_MemoryButtons, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(91, 91, 91)
                                .addComponent(jL_Title, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(72, 72, 72)
                                .addComponent(jTA_Pantalla, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 85, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jTB_OnOff, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31)
                        .addComponent(jLP_Tune, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jL_Title)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTA_Pantalla, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLP_MemoryButtons, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLP_Band, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLP_Band.getAccessibleContext().setAccessibleName("jLP_Band");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTB_OnOffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTB_OnOffActionPerformed
        if(Radio.isOn()){
            disableRadio();
            Radio.onOff();
        }
        else {
            enableRadio();
            Radio.onOff();
        }
    }//GEN-LAST:event_jTB_OnOffActionPerformed

    private void jRB_AMMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRB_AMMouseReleased
        if(jRB_FM.isSelected()){
            jRB_FM.setSelected(false);
            Radio.cambiarBanda();
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jRB_AMMouseReleased

    private void jRB_FMMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRB_FMMouseReleased
        if(jRB_AM.isSelected()){
            jRB_AM.setSelected(false);  
            Radio.cambiarBanda();
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jRB_FMMouseReleased

    private void jB_UpMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_UpMouseReleased
        Radio.cambiarFrecuencia();
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_UpMouseReleased

    private void jB_M1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M1MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M1MousePressed

    private void jB_M2MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M2MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M2MousePressed

    private void jB_M3MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M3MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M3MousePressed

    private void jB_M4MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M4MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M4MousePressed

    private void jB_M5MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M5MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M5MousePressed

    private void jB_M6MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M6MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M6MousePressed

    private void jB_M7MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M7MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M7MousePressed

    private void jB_M8MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M8MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M8MousePressed

    private void jB_M9MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M9MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M9MousePressed

    private void jB_M10MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M10MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M10MousePressed

    private void jB_M11MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M11MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M11MousePressed

    private void jB_M12MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M12MousePressed
        inicioTiempo = System.currentTimeMillis();
    }//GEN-LAST:event_jB_M12MousePressed

    //Métodos para los botones de memoria.
    private void jB_M1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M1MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(1);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(1);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(1);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M1MouseReleased

    private void jB_M2MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M2MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(2);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(2);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(2);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M2MouseReleased

    private void jB_M3MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M3MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(3);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(3);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(3);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M3MouseReleased

    private void jB_M4MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M4MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(4);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(4);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(4);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M4MouseReleased

    private void jB_M5MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M5MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(5);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(5);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(5);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M5MouseReleased

    private void jB_M6MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M6MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(6);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(6);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(6);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M6MouseReleased

    private void jB_M7MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M7MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(7);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(7);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(7);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M7MouseReleased

    private void jB_M8MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M8MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(8);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(8);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(8);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M8MouseReleased

    private void jB_M9MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M9MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(9);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(9);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(9);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M9MouseReleased

    private void jB_M10MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M10MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(10);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(10);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(10);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M10MouseReleased

    private void jB_M11MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M11MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(11);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(11);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(11);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M11MouseReleased

    private void jB_M12MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_M12MouseReleased
        finalTiempo = System.currentTimeMillis();
        finalTiempo = finalTiempo - inicioTiempo;
        if (finalTiempo > 4000){
            Radio.guardarEstacion(12);
        }else{
            float frecuenciax = Radio.getFrecuencia();
            Radio.seleccionarEstacion(12);
            if(Radio.getFrecuencia() == frecuenciax) {
                Radio.guardarEstacion(12);
            }
        }
        jTA_Pantalla.setText(num.format(Radio.getFrecuencia()));
    }//GEN-LAST:event_jB_M12MouseReleased

    private void disableRadio() {
        jB_M1.setEnabled(false);
        jB_M2.setEnabled(false);
        jB_M3.setEnabled(false);
        jB_M4.setEnabled(false);
        jB_M5.setEnabled(false);
        jB_M6.setEnabled(false);
        jB_M7.setEnabled(false);
        jB_M8.setEnabled(false);
        jB_M9.setEnabled(false);
        jB_M10.setEnabled(false);
        jB_M11.setEnabled(false);
        jB_M12.setEnabled(false);
        jB_Up.setEnabled(false);
        jRB_AM.setEnabled(false);
        jRB_FM.setEnabled(false);
        jTA_Pantalla.setEnabled(false);
        jLP_Band.setEnabled(false);
        jLP_Tune.setEnabled(false);
        jL_Title.setEnabled(false);
        jRB_AM.setEnabled(false);
        jRB_FM.setEnabled(false);
    }
    
    private void enableRadio(){
        jB_M1.setEnabled(true);
        jB_M2.setEnabled(true);
        jB_M3.setEnabled(true);
        jB_M4.setEnabled(true);
        jB_M5.setEnabled(true);
        jB_M6.setEnabled(true);
        jB_M7.setEnabled(true);
        jB_M8.setEnabled(true);
        jB_M9.setEnabled(true);
        jB_M10.setEnabled(true);
        jB_M11.setEnabled(true);
        jB_M12.setEnabled(true);
        jB_Up.setEnabled(true);
        jRB_AM.setEnabled(true);
        jRB_FM.setEnabled(true);
        jLP_Band.setEnabled(true);
        jLP_Tune.setEnabled(true);
        jL_Title.setEnabled(true);
        jRB_AM.setEnabled(true);
        jRB_FM.setEnabled(true);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jB_M1;
    private javax.swing.JButton jB_M10;
    private javax.swing.JButton jB_M11;
    private javax.swing.JButton jB_M12;
    private javax.swing.JButton jB_M2;
    private javax.swing.JButton jB_M3;
    private javax.swing.JButton jB_M4;
    private javax.swing.JButton jB_M5;
    private javax.swing.JButton jB_M6;
    private javax.swing.JButton jB_M7;
    private javax.swing.JButton jB_M8;
    private javax.swing.JButton jB_M9;
    private javax.swing.JButton jB_Up;
    private javax.swing.JLayeredPane jLP_Band;
    private javax.swing.JLayeredPane jLP_MemoryButtons;
    private javax.swing.JLayeredPane jLP_Tune;
    private javax.swing.JLabel jL_Title;
    private javax.swing.JRadioButton jRB_AM;
    private javax.swing.JRadioButton jRB_FM;
    private javax.swing.JTextArea jTA_Pantalla;
    private javax.swing.JToggleButton jTB_OnOff;
    // End of variables declaration//GEN-END:variables
}
